package libnetdb.dm.assoc.base;
import java.util.*;

class LitemsetNode {
    private Litemset litemset = null;
    private ArrayList parents = new ArrayList(); 
    private ArrayList children = new ArrayList();

    public LitemsetNode(Litemset litemset){
        this.litemset = litemset;
    }

    public Litemset getLitemset(){
        return litemset;
    }

    public Collection getChildren(){
        return children;
    }

    public Collection getParents(){
        return parents;
    }

    public void removeChild(LitemsetNode node){
        children.remove(node);
        ((LitemsetNode)node).parents.remove(this);
    }

    public void addChild(LitemsetNode node){
        children.add(node);
        ((LitemsetNode)node).parents.add(this);
    }
    
    public LatticeIterator ancestorIterator(){
        return new LatticeIterator(this){
			protected Collection nextLevel(Object object) {                
                return ((LitemsetNode)object).parents;
			}
        };
    }
    
    public LatticeIterator decesterIterator(){
        return new LatticeIterator(this){
            protected Collection nextLevel(Object object) {
                return ((LitemsetNode)object).children;
            }
        };
    }

}